/*
 * Copyright (c) 2025 Li Auto Inc. and its affiliates
 * Licensed under the Apache License, Version 2.0(the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <arch/irq.h>
#include "tricore_internal.h"

bool is_privilege_mode(void)
{
  uintptr_t psw = (uintptr_t)__mfcr(TX3XX_CPU_PSW);

  return (((psw & PSW_IO_SUPERVISOR) != 0u) ? TRUE: FALSE);
}

void up_syscall(void *syscall_args)
{
  sys_call2(SYS_syscall_return, (uintptr_t)syscall_args, (uintptr_t)0);
}
